﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Register.aspx.cs" Inherits="Web.WebRegister" %>

<!DOCTYPE html>


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" />
    <title>注册</title>
     <link href="../../App_Themes/asserts/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="../../App_Themes/asserts/css/signin.css" rel="stylesheet" type="text/css" />
    <script src="../App_Themes/js/jQuery-1.11.3.js"></script>
    <script src="../App_Themes/asserts/js/popper.min.js" type="text/javascript"></script>
    <script src="../App_Themes/js/bootstrap.min.js" type="text/javascript"></script>
    <script>
        $(function () {
            // 注册按钮的条件
            var isOk = [0, 0, 0, 0, 0, 0];

            // 判断是否可以点击注册
            var enbaleBtnReg = function () {
                for (var i = 0; i < 5; i++) {
                    if (isOk[i] == 0) {
                        $("#btnRegister").attr("disabled", true);
                        return;
                    }
                }
                $("#btnRegister").removeAttr("disabled");
            };

            // 用户名验证
            $("#TextUsername").blur(function () {
                var nameReg = /^[a-zA-Z0-9_]{1,}$/;
                if (!$(this).val().match(nameReg)) {
                    $(this).popover('show');
                    isOk[0] = 0;
                } else {
                    isOk[0] = 1;
                    $(this).popover('hide');
                    $("#btnRegister").removeAttr("disabled");
                }
            });
            // 密码验证
            $("#TextPassword").blur(function () {
                var pwdReg = /^[A-Za-z0-9_]+$/;
                if (!$(this).val().match(pwdReg)) {
                    isOk[1] = 0;
                    $(this).popover('show');
                } else {
                    isOk[1] = 1;
                    $(this).popover('hide');
                    $("#btnRegister").removeAttr("disabled");
                }
            });
            // 重复密码验证
            $("#TextRepassword").blur(function () {
                if ($(this).val() == $("#TextPassword").val()) {
                    isOk[2] = 1;
                    $(this).popover('hide');
                    $("#btnRegister").removeAttr("disabled");
                } else {
                    isOk[2] = 0;
                    $(this).popover('show');
                }
            });
            // 电子邮件验证
            $("#TextEmail").blur(function () {
                var emailReg = /^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/;
                if (!$(this).val().match(emailReg)) {
                    isOk[3] = 0;
                    $(this).popover('show');
                } else {
                    isOk[3] = 1;
                    $(this).popover('hide');
                    $("#btnRegister").removeAttr("disabled");
                }
            });
            // 问题验证
            $("#TextTelephone").blur(function () {
                var telephoneReg = /^1[3456789]d{9}$/;
                if (!$(this).val().match(telephoneReg)) {
                    isOk[4] = 1;
                    $(this).popover('hide');
                    $("#btnRegister").removeAttr("disabled");
                } else {
                    isOk[4] = 0;
                    $(this).popover('show');
                }
            });

            // 注册验证
            $("#btnRegister").mousemove(function () {
                $("#TextUsername").blur();
                $("#TextPassword").blur();
                $("#TextRepassword").blur();
                $("#TextEmail").blur();
                $("#TextTelephone").blur();
                enbaleBtnReg();
            });

        });

        // 回车注册事件取消
        function EnterKeyFilter() {
            if (window.event.keyCode == 13) {
                event.returnValue = false;
                event.cancel = true;
            }
        }
    </script>
</head>


<body class="text-center" onkeydown="javascript:EnterKeyFilter();">
    <form class="form-signin"  role="form" runat="server">
        <img class="mb-4" src="../App_Themes/images/header.png" alt="" height="100">
        <h1 class="h3 mb-3 font-weight-normal">与你相遇，三生有幸</h1>
        <asp:Label style="color: #FF0000" ID="ErrorInfo" runat="server" Text=""></asp:Label>
        <label class="sr-only">用户名</label>
        <asp:TextBox class="form-control" ID="TextUsername" runat="server" placeholder="请输入用户名" data-placement="right" data-content="只可以是数字字母和下划线" MaxLength="20"></asp:TextBox>
        <label class="sr-only">密码</label>
        <asp:TextBox type="password" class="form-control" ID="TextPassword" runat="server" placeholder="请输入密码" data-placement="right" data-content="由数字 字母和下划线组成" MaxLength="16"></asp:TextBox>
        <label class="sr-only">重复密码</label>
        <asp:TextBox type="password" class="form-control" ID="TextRepassword" runat="server" placeholder="再次输入密码" data-placement="right" data-content="再次输入上一次的密码" MaxLength="16"></asp:TextBox>
        <label class="sr-only">邮箱</label>
        <asp:TextBox type="email" class="form-control" ID="TextEmail" runat="server" placeholder="请输入邮箱" data-placement="right" data-content="例：example@domain.com"></asp:TextBox>
        <label class="sr-only">联系电话</label>
        <asp:TextBox type="text" class="form-control" ID="TextTelephone" runat="server" placeholder="请输入您的联系方式" data-placement="right" data-content="找回密码的问题"></asp:TextBox>
        <div class="checkbox mb-3">
            <label>
                
            </label>
        </div>
        <asp:Button ID="btnRegister" class="btn btn-lg btn-primary btn-block" runat="server" Text="注册" OnClick="btnRegister_Click" />
        <asp:HyperLink class="btn btn-link" ID="HyperLink1" runat="server" NavigateUrl="~/Web/Login.aspx">已有账号？直接登录</asp:HyperLink>
        <p class="mt-5 mb-3 text-muted">©  2021-2022</p>
    </form>

</body>

</html>
